package com.qf.controller;


import com.qf.utils.UploadUtils;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

/**
 * 七牛与上传图片
 */
@Controller
@RequestMapping("/QiNiuYunUpload")
public class QiNiuYunUploadController {

    @RequestMapping("/img")
    public String uloadFile(@RequestParam("file") MultipartFile multipartFile, Model model){


        //使用自定义工具类,用到了七牛云的sdk
        String uploadFile = UploadUtils.uploadFile(multipartFile);

        //存储Model中
        model.addAttribute("imgUrl",uploadFile) ;

        return "upload_ok" ;
    }
}
